package test;

public class Account {
    public Account (int id, double balance, double annualInterestRate ){
            this.id=id;
            this.balance=balance;
            this.annualInterestRate=annualInterestRate;
    }
    private int id;
    protected double balance;
    private double annualInterestRate;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public double getAnnualInterestRate() {
        return annualInterestRate;
    }

    public void setAnnualInterestRate(double annualInterestRate) {
        this.annualInterestRate = annualInterestRate;
    }

    public double getMonthlyInterest(){
        double MonthlyInterest =annualInterestRate/12;
        return MonthlyInterest;
    }
    public void withdraw (double amount){
        if(amount>balance){
            System.out.println("余额不足");
        }else{
            this.balance-=amount;
            System.out.println("你的余额为："+this.balance);
        }
    }
    public void deposit (double amount){
        this.balance+=amount;
        System.out.println("你的余额为："+this.balance);
        System.out.println("你的月利率为："+getMonthlyInterest());
    }

}
